/*/////////////////////////////////////////////////////////////////////////////////
/// An
///    ___   ____ ___ _____ ___  ____
///   / _ \ / ___|_ _|_   _/ _ \|  _ \
///  | | | | |  _ | |  | || | | | |_) |
///  | |_| | |_| || |  | || |_| |  _ <
///   \___/ \____|___| |_| \___/|_| \_\
///                              File
///
/// Copyright (c) 2008-2009 Ismail TARIM <ismail@royalspor.com> and the Ogitor Team
//
//This program is free software; you can redistribute it and/or modify it under
//the terms of the GNU Lesser General Public License as published by the Free Software
//Foundation; either version 2 of the License, or (at your option) any later
//version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT
//ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
//FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public License along with
//this program; if not, write to the Free Software Foundation, Inc., 59 Temple
//Place - Suite 330, Boston, MA 02111-1307, USA, or go to
//http://www.gnu.org/copyleft/lesser.txt.
////////////////////////////////////////////////////////////////////////////////*/

#pragma once

namespace Ogitors
{

class OgitorExport CSceneManagerEditor: public CBaseEditor
{
    friend class CSceneManagerEditorFactory;
public:
	static OgitorsPropertyDefMap propertyDefs;

    /// Returns the Factory associated with this object
	static CBaseEditorFactory   *getFactory();
    /// Returns the Factory associated with this object can be overridden
	virtual CBaseEditorFactory  *getFactoryDynamic();

    void              setSceneManagerType(const Ogre::String& value, bool display) {};
    Ogre::String      getSceneManagerType();
    void              setConfigFile(const Ogre::String& value, bool display);
    Ogre::String      getConfigFile();
    void              setAmbient(const Ogre::ColourValue& value, bool display);
    Ogre::ColourValue getAmbient();
    void              setSkyboxMaterial(const Ogre::String& value, bool display);
    Ogre::String      getSkyboxMaterial();
    void              setSkyboxDistance(const Ogre::Real& value, bool display);
    Ogre::Real        getSkyboxDistance();
    void              setSkyboxActive(const bool& value, bool display);
    bool              getSkyboxActive();
    void              setFogMode(const int& value, bool display);
    int               getFogMode();
    void              setFogStart(const Ogre::Real& value, bool display);
    Ogre::Real        getFogStart();
    void              setFogEnd(const Ogre::Real& value, bool display);
    Ogre::Real        getFogEnd();
    void              setFogColour(const Ogre::ColourValue& value, bool display);
    Ogre::ColourValue getFogColour();
    void              setFogDensity(const Ogre::Real& value, bool display);
    Ogre::Real        getFogDensity();
    void              setPosition(const Ogre::Vector3& position, bool display) {};
    Ogre::Vector3     getPosition() {return Ogre::Vector3::ZERO;};
    void              setOrientation(const Ogre::Quaternion& orientation, bool display) {};
    Ogre::Quaternion  getOrientation(){return Ogre::Quaternion::IDENTITY;};
    void              setScale(const Ogre::Vector3& scale, bool display) {};
    Ogre::Vector3     getScale() {return Ogre::Vector3(1,1,1);};
    
    virtual bool            load();
    virtual bool            unLoad();
    virtual void            processParameters(Ogre::NameValuePairList &params);
    virtual void            getObjectProperties(Ogre::NameValuePairList &retList);
	virtual bool			setupPropertiesWnd(bool present);
	virtual bool            isNodeType() {return true;};
	virtual void            showBoundingBox(bool bShow) {};
    virtual bool            handleCustomFunction(int BIND_ID, Ogre::String val);

	/// This function is called when user right clicks a property to get that property specific popup menu
	/// returns false if no menu present (Disabled Menu Items has a "D" prefix where Enabled Menu Items have "E" prefix
	virtual bool                 getObjectContextMenu(UTFStringVector &menuitems);
    /// This function is called when user selects a menuitem from ContextMenu
	virtual void                 onObjectContextMenu(int menuresult);
    /// General Purpose Update Function Used By OgitorsRoot Override for Descendants
    virtual bool                 postSceneUpdate(Ogre::SceneManager *SceneMngr, Ogre::Camera *Camera, Ogre::RenderWindow *RenderWindow);
    /// Overridden by Editor Objects to Import Object Dependant Properties
    virtual void                 restore(Ogre::NameValuePairList &retList);
    /// Gets the Handle to encapsulated object
    inline virtual void         *getHandle() {return static_cast<void*>(m_Handle);};
    virtual Ogre::AxisAlignedBox getAABB() {return m_Handle->getRootSceneNode()->_getWorldAABB();};

	virtual Ogre::SceneNode     *getNode() {return m_Handle->getRootSceneNode();};
	virtual Ogre::SceneManager  *getSceneManager() {return m_Handle;};

	virtual void                 setNameImpl(Ogre::String name, bool display);

protected:
	Ogre::SceneManager *m_Handle;
    Ogre::String        m_SceneManagerType;
    Ogre::String        m_ConfigFile;
    Ogre::ColourValue   m_Ambient;
    Ogre::String        m_SkyBoxMaterial;
	float               m_SkyBoxDistance;
	bool                m_SkyBoxActive;
    int                 m_FogMode;
    Ogre::ColourValue   m_FogColour;
    Ogre::Real          m_FogStart;
    Ogre::Real          m_FogEnd;
    Ogre::Real          m_FogDensity;

	CSceneManagerEditor();
	virtual            ~CSceneManagerEditor() {};
};

class OgitorExport CSceneManagerEditorFactory: public CBaseEditorFactory
{
public:
  CSceneManagerEditorFactory();
  virtual ~CSceneManagerEditorFactory() {};
  virtual void Init();
  virtual CBaseEditor *CreateObject(CBaseEditor **parent, Ogre::NameValuePairList &params);
};
}



